package com.example.tool.util.ExpressDeliveryUtil;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum TrackTypeEnum {
    //COLLECTION 揽收, SENDER 发件,RECEIVED 到件,DELIVERY 派件,ARRIVAL 代收,TRANSFER_ORDER 转单,GIVEBACK 退回,SIGNED 签收
    NOT_COLLECTED("NOT_COLLECTED", "未知"),
    COLLECTION("COLLECTION", "揽收"),
    SENDER("SENDER", "发件"),
    RECEIVED("RECEIVED", "到件"),
    DELIVERY("DELIVERY", "派件"),
    ARRIVAL("ARRIVAL", "代收"),
    TRANSFER_ORDER("TRANSFER_ORDER", "转单"),
    GIVEBACK("GIVEBACK", "退回"),
    SIGNED("SIGNED", "签收");
    private final String code;
    private final String description;

    TrackTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static String byTypeGetDescription(String code){
        Optional<TrackTypeEnum> first = Arrays.stream(TrackTypeEnum.values()).filter(e -> ObjectUtil.equals(e.code, code)).findFirst();
        if (first.isPresent()) {
         return first.get().description;
        }
        return "";
    }

//    public static void main(String[] args) {
//        System.out.println(byTypeGetDescription(""));
//        System.out.println(byTypeGetDescription("ARRIVAL"));
//    }
}
